﻿<template>
  <a-collapse activeKey="1" expand-icon-position="right">
    <a-collapse-panel key="1" header="查询条件">
      <a-form-model :model="params" ref="paramsForm" :labelCol="{ md: { span: 6 }, xs: { span: 24 }, sm: { span: 12 } }" :wrapperCol="{ md: { span: 18 }, xs: { span: 24 }, sm: { span: 12 } }">
        <a-row>
          <a-col :xs='24' :sm='24' :md='6' :lg='6' :xl='6' :xxl='6'>
            <a-form-model-item label='账号'>
              <a-input v-model.trim='params.account' placeholder='请输入账号' v-keyupEnter='{ callback: handleRefresh }' />
            </a-form-model-item>
          </a-col>
          <a-col :xs='24' :sm='24' :md='6' :lg='6' :xl='6' :xxl='6'>
            <a-form-model-item label='所属站点'>
              <a-select allowClear show-search v-model.trim='params.tenantId'>
                <a-select-option v-for="item in tenantIdsList" :key="item.id" :value="item.id">{{ item.name }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :xs='24' :sm='24' :md='6' :lg='6' :xl='6' :xxl='6'>
            <a-form-model-item label='所属用户'>
              <a-select allowClear show-search v-model.trim='params.userId' placeholder="请选择所属用户" style="width: 100%">
                <a-select-option v-for="item in userList" :key="item.id" :value="item.id">{{ item.nickName }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col> -->
          <a-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" :xxl="6" style="text-align: right">
            <a-form-model-item>
              <a-button icon="search" type="primary" :loading="loading" @click="handleRefresh">查询</a-button>
              <a-divider type="vertical" />
              <a-button icon="reload" @click="handleReset">重置</a-button>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-collapse-panel>
  </a-collapse>
</template>
<script>
import { queryTenantsList } from "@/views/tenantsModule/tenants/tenants";
import { queryUserList } from '@/views/userModule/user/user'
export default {
  props: {
    loading: {
      type: Boolean,
    },
  },
  data() {
    return {
      userList: [],
      // 要查询的参数
      params: {
        account: null,
        tenantId: null,
      },
      tenantIdsList: [],
    }
  },
  created() {
    // queryUserList().then(res => {
    //   this.userList = res.data
    // });
    queryTenantsList().then((res) => {
      this.tenantIdsList = res.data;
    });
  },
  methods: {

    //#region 查询数据
    handleRefresh() {
      this.$emit('handleRefresh')
    },
    //#endregion

    //#region 重置
    handleReset() {
      this.params.account = ''
      this.params.tenantId = ''
    },
    //#endregion
  },
}
</script>
